<?php
namespace App\Repositories\Attendance;

use Illuminate\Http\Request;


class AttendanceFilter
{
    protected $perPage;
    protected $sort;
    protected $name;
    protected $workType;
    protected $departmentName;
    protected $startTime;
    protected $endTime;
    protected $userId;

    public function __construct(Request $request)
    {
        $this->name = $request->get('name');
        $this->workType = $request->get('work_type');
        $this->departmentName = $request->get('department_name');
        $this->startTime = $request->get('start_time');
        $this->endTime = $request->get('end_time');
        $this->userId = $request->get('user_id');
        $this->perPage = max(min((int)$request->get('per_page', 20), 100), 1);
        $this->sort = parseSortString($request->get('sort'));
    }

    /**
     * @return mixed
     */
    public function getUserId()
    {
        return $this->userId;
    }

    /**
     * @return mixed
     */
    public function getWorkType()
    {
        return $this->workType;
    }

    /**
     * @return mixed
     */
    public function getStartTime()
    {
        return $this->startTime;
    }

    /**
     * @return mixed
     */
    public function getEndTime()
    {
        return $this->endTime;
    }

    /**
     * @return mixed
     */
    public function getDepartmentName()
    {
        return $this->departmentName;
    }

    /**
     * @return mixed
     */
    public function getPerPage()
    {
        return $this->perPage;
    }

    /**
     * @return array
     */
    public function getSort(): array
    {
        return $this->sort;
    }

    /**
     * @return mixed
     */
    public function getName()
    {
        return $this->name;
    }
}
